{% extends 'teachers/base.html' %}
{% block teachers_index %}
    {% load static %}
    <div class="container">
        <br>
        <h3>&emsp;{{ course.name }}</h3>
        <hr>
        {% for i in exercises %}



            <div class="alert alert-primary text-black" role="alert">

                <div class="row">
                    <div class="col-md-9">
                        <h5>{{ i.exercises }}</h5>
                        <p>

                            题目数量：{{ i.answer_set.count }} ，总分：{{ i.answer_set.count }}，创建时间：{{ i.myTime }}
                        </p>
                    </div>
                    <div class="col-3 text-center">
                        <p></p>
                        <a href="{% url 'exercises_edit'  i.id %}" class="btn btn-primary w-25 ">编辑</a>

                        <!-- Button trigger modal -->
                        <button type="button" class="btn btn-danger btn w-25" data-bs-toggle="modal"
                                data-bs-target="#staticBackdrop_my{{ i.id }}">
                            删除
                        </button>

                        <!-- Modal -->
                        <div class="modal fade" id="staticBackdrop_my{{ i.id }}" data-bs-backdrop="static"
                             data-bs-keyboard="false"
                             tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="staticBackdropLabel">确定删除吗？</h5>
                                        <button type="button" class="btn-close" data-bs-dismiss="modal"
                                                aria-label="Close"></button>
                                    </div>
                                    <div class="modal-body text-start">
                                        确定删除“{{ i.exercises }}”吗？
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消
                                        </button>
                                        <a href="{% url 'exercises_del' course.id i.id %}" type="button"
                                           class="btn btn-danger">确定删除</a>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>

            </div>
        {% empty %}
            <div class="text-center " style="height: 150px;">
                <h4 style="margin-top: 50px;color: #1c51a1">请添加练习题！</h4>
            </div>
        {% endfor %}
        <br>

        <!-- Button trigger modal -->
        <div class="text-end">
            <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop_add">
                <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="currentColor"
                     class="bi bi-plus-lg"
                     viewBox="0 0 16 16">
                    <path fill-rule="evenodd"
                          d="M8 2a.5.5 0 0 1 .5.5v5h5a.5.5 0 0 1 0 1h-5v5a.5.5 0 0 1-1 0v-5h-5a.5.5 0 0 1 0-1h5v-5A.5.5 0 0 1 8 2Z"/>
                </svg>
                &nbsp;添加练习题
            </button>

            <!-- Modal -->
            <div class="modal fade" id="staticBackdrop_add" data-bs-backdrop="static" data-bs-keyboard="false"
                 tabindex="-1"
                 aria-labelledby="staticBackdropLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <form action="{% url 'exercises_add' course.id %}" method="get">
                            <div class="modal-header">
                                <h5 class="modal-title" id="staticBackdropLabel">&emsp;添加练习题 </h5>
                                <button type="button" class="btn-close" data-bs-dismiss="modal"
                                        aria-label="Close"></button>
                            </div>
                            <div class="modal-body">
                                <div class="text-start">
                                    <div class="mb-3">
                                        <label class="form-label">练习题名</label>
                                        <input name="name" type="text" class="form-control">

                                    </div>

                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary">确定</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>





{% endblock %}